package com.example.controller.flowable.adm;
import com.example.service.flowable.adm.IVehiclesService;
import com.example.vo.ResultVo;
import com.example.vo.adm.VehicleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apiguardian.api.API;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.transform.Result;

/*
 * 车辆申请控制流程
 */


@RestController
@RequestMapping("/process/vehicle")
@Api(tags = "车辆申请管理")
public class VehiclesController {

    @Autowired
    private IVehiclesService vehiclesService;

    @PostMapping("/create")
    @ApiOperation(value = "新建车辆申请流程")
    public ResultVo addVehicleflowable(@RequestBody VehicleVo vehicleVo){
        return vehiclesService.addVehicleflowable(vehicleVo);
    }

    @GetMapping("/assessing-officer")
    @ApiOperation(value = "获取审批人员")
    public ResultVo getAssessingOfficer(){
        return vehiclesService.getAssessingOfficer();
    }

    @GetMapping("/my-task")
    @ApiOperation(value = "我的审批任务")
    public ResultVo getMyTask(String empId){
        return vehiclesService.getMyTask(empId);
    }

    @PutMapping("/do-audit")
    @ApiOperation(value = "完成审批")
    public ResultVo doAudit(@RequestParam("taskId") String taskId,@RequestParam("approved") Boolean approved,@RequestParam(value = "reply",required = false) String reply,
                            @RequestParam(value = "licensePlate",required = false)String licensePlate,@RequestParam(value = "processInstanceId")String processInstanceId){
        return vehiclesService.doAudit(taskId,approved,reply,licensePlate,processInstanceId);
    }

    @GetMapping("/getAllPy")
    @ApiOperation(value = "查询所有车辆申请")
    public ResultVo getAllPy(){
        return vehiclesService.getAllPy();
    }
}
